package com.yanqu.road.server.manger.activity.zhounianturntable;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.zhounianturntable.ZhouNianTurntableConfig;
import com.yanqu.road.entity.enums.eActivityConfigType;
import com.yanqu.road.logic.bussiness.activity.ZhouNianTurntableBusiness;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ZhouNianTurntableActivity {

    public ActivityInfo activityInfo;

    /**
     * 宝盘配置 档位id,配置
     */
    public Map<Integer, ZhouNianTurntableConfig> configMap = new ConcurrentHashMap<>();

    public int ZHOUNIAN_TURNTABLE_ITEM_ID;

    public int ZHOUNIAN_TURNTABLE_ITEM_COUNT;

    public String ZHOUNIAN_TURNTABLE_RECYCLE;

    public ZhouNianTurntableActivity(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public boolean save() {
        return true;
    }

    public boolean init() {
        reloadActivity(activityInfo);
        return true;
    }

    public boolean reloadActivity(ActivityInfo activityInfo) {
        // 加载配置
        Map<String, ActivityConfig> activityConfigMap = NormalActivityMgr.getActivityConfigMap(activityInfo.getActivityId());
        if (activityConfigMap.containsKey(eActivityConfigType.ZHOUNIAN_TURNTABLE_ITEM_ID.getName())) {
            String itemPara = activityConfigMap.get(eActivityConfigType.ZHOUNIAN_TURNTABLE_ITEM_ID.getName()).getValue();
            String[] split = itemPara.split("=");
            ZHOUNIAN_TURNTABLE_ITEM_ID = Integer.parseInt(split[0]);
            ZHOUNIAN_TURNTABLE_ITEM_COUNT = Integer.parseInt(split[1]);
        }
        if (activityConfigMap.containsKey(eActivityConfigType.ZHOUNIAN_TURNTABLE_RECYCLE.getName())) {
            ZHOUNIAN_TURNTABLE_RECYCLE = activityConfigMap.get(eActivityConfigType.ZHOUNIAN_TURNTABLE_RECYCLE.getName()).getValue();
        }
        configMap = ZhouNianTurntableBusiness.getZhouNianTurntableConfigMap(activityInfo.getActivityId());
        return true;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }
}
